32 lines
731 B
Plaintext
32 lines
731 B
Plaintext
---
|
|
import Layout from "../../layouts/Layout.astro";
|
|
import Content from "../../components/Content.astro";
|
|
import type { Post } from "../../types";
|
|
import { getPost, getPosts } from "../../utils/payload";
|
|
|
|
export async function getStaticPaths() {
|
|
const posts = await getPosts();
|
|
const paths = posts.map((post: Post) => ({
|
|
params: { id: post.id },
|
|
}));
|
|
return paths;
|
|
}
|
|
|
|
const { id } = Astro.params;
|
|
const post = id && (await getPost(id));
|
|
---
|
|
|
|
{
|
|
post ? (
|
|
<Layout title={`Astroad | ${post.title!}`}>
|
|
<div class="space-y-3 my-3">
|
|
<a href="/">BACK</a>
|
|
<h1>{post.title}</h1>
|
|
{post.content && <Content content={post.content} />}
|
|
</div>
|
|
</Layout>
|
|
) : (
|
|
<div>404</div>
|
|
)
|
|
}
|